import csv
import os

import pandas as pd

root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


def read_csv(file_path):
    data_path = os.path.join(root_path, 'data', file_path)
    with open(data_path, encoding='utf-8') as f:
        reader = csv.DictReader(f)
        data = [list(row.values()) for row in reader]
    return data


def read_excel(file_path):
    data_path = os.path.join(root_path, 'data', file_path)
    df = pd.read_excel(data_path)
    return df.to_dict(orient='records')
